#
#	Makefile for oficonv/apps
#

@SET_MAKE@

SHELL = /bin/sh
VPATH = @srcdir@:@top_srcdir@/include:@top_srcdir@/@configdir@/include
srcdir = @srcdir@
top_srcdir = @top_srcdir@
configdir = @top_srcdir@/@configdir@

include $(configdir)/@common_makefile@

ofstddir = $(top_srcdir)/../ofstd

LOCALINCLUDES = -I$(ofstddir)/include -I$(top_srcdir)/libsrc
LIBDIRS = -L$(top_srcdir)/libsrc
LOCALLIBS = -loficonv

objs = mkcsmapper_bison.o mkcsmapper_flex.o mkesdb_bison.o mkesdb_flex.o
progs = mkcsmapper mkesdb


all: $(progs)

mkcsmapper: mkcsmapper_bison.o mkcsmapper_flex.o
	$(CXX) $(CXXFLAGS) $(LIBDIRS) $(LDFLAGS) -o $@ mkcsmapper_bison.o mkcsmapper_flex.o $(LOCALLIBS) $(LIBS)

mkesdb: mkesdb_bison.o mkesdb_flex.o
	$(CXX) $(CXXFLAGS) $(LIBDIRS) $(LDFLAGS) -o $@ mkesdb_bison.o mkesdb_flex.o $(LOCALLIBS) $(LIBS)

# special make target "run_flex_and_bison". This re-builds the source code
# for mkcsmapper and mkesdb from the flex and bison rule files.

run_flex_and_bison:
	flex --outfile=$(top_srcdir)/apps/mkcsmapper_flex.cc mkcsmapper.l
	flex --outfile=$(top_srcdir)/apps/mkesdb_flex.cc mkesdb.l
	bison --defines=$(top_srcdir)/apps/mkcsmapper_bison.h --output=$(top_srcdir)/apps/mkcsmapper_bison.cc mkcsmapper.y
	bison --defines=$(top_srcdir)/apps/mkesdb_bison.h --output=$(top_srcdir)/apps/mkesdb_bison.cc mkesdb.y


install: all
	$(configdir)/mkinstalldirs $(DESTDIR)$(bindir)
	for prog in $(progs); do \
		$(INSTALL_PROGRAM) $$prog$(BINEXT) $(DESTDIR)$(bindir) && $(STRIP) $(DESTDIR)$(bindir)/$$prog$(BINEXT) ;\
	done


clean:
	rm -f $(objs) $(progs) $(TRASH)

distclean:
	rm -f $(objs) $(progs) $(DISTTRASH)


dependencies:
	$(CXX) -MM $(defines) $(includes) $(CPPFLAGS) $(CXXFLAGS) *.cc  > $(DEP)

include $(DEP)
